package at.com.vn.chess.applet;

import java.awt.Dimension;
import java.util.Random;

import javax.swing.JApplet;

import at.com.vn.chess.listener.ChessTableListener;
import at.com.vn.chess.util.Const;

@SuppressWarnings( "serial" )
public class DummyApplet extends JApplet {

	public static final String URL_CHESS_APPLICATION = "http://localhost:8080/shogi";
	private String url_servlet_chat_private = URL_CHESS_APPLICATION + "/chatPrivate.htm";

	String name = "nghi";
	String currentRoomID = "room1";
	int tableID = 1;

	ChessPanel chessDialog;
	ChessTableListener listener;

	public void init() {
//		Dimension size = new Dimension( Const.DIALOG_WIDTH, Const.DIALOG_HEIGHT + 25 );
//		ChessFrame chessFrame = new ChessFrame( this );
		java.awt.EventQueue.invokeLater(new Runnable()
        {
            public void run()
           {
            	Random random = new Random();
        		name += random.nextInt(100);
        		ChessFrame chessFrame = new ChessFrame( "nghi table", url_servlet_chat_private, name, currentRoomID, tableID, DummyApplet.this );
//        		chessFrame.setSize( size );
//        		chessFrame.setMinimumSize( size );

        		listener = new ChessTableListener() {

        			@Override
        			public void refreshMainBoard() {
        				// TODO Auto-generated method stub

        			}

        			@Override
        			public void setPlayerClicked( String name, int playerColor,
        					String status ) {
        				System.out.println( name );
        			}

        		};

        		chessFrame.setListener( listener );

//        		chessDialog.setSize( size );
//        		chessFrame.setLocationRelativeTo( null );

//        		chessFrame.setPreferredSize( new Dimension( Const.DIALOG_WIDTH, Const.DIALOG_HEIGHT ) );
//        		chessFrame.pack();
//        		chessFrame.setLocationRelativeTo( null );
        		chessFrame.setVisible( true );
        		chessFrame.setMinimumSize( new Dimension( Const.DIALOG_WIDTH, Const.DIALOG_HEIGHT + 32 ) );
            }
        });

	}
}